<?php
require_once FOREGROUND_COMMON_ACTION_SERVICE_DIR . '/ajax.php';

class foreground_address_region_get_region_list_action_service extends foreground_ajax_common_action_service
{
    protected static $_instance;

    public static function get_instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }


    protected function _current_page_process()
    {	     		     
	    //var_dump(__METHOD__); exit();
	
	    $result = array('status' => 0, 'message' => '', 'data' => array());
	    
	    //模拟数据
	    //$pid = 0;
	    //$pid = 1;	    
	    $pid = init_user_data_key($_GET, 'pid', 'int'); 
	    //$level = 1;
	    $level = init_user_data_key($_GET, 'level', 'int');
	    
        if(empty($pid)){
            $result['status']  = -400;
            $result['message'] = '请选择有效的区域';
        }else if(empty($level)){
            $result['status']  = -400;
            $result['message'] = '请选择有效的区域';
        }else{
            $model_foreground_address_region = wwy_resource_container::get_model_foreground_address_region();
            //var_dump($model_foreground_address_region); exit();
                           
            $if_id_key = false;
            $region_list = $model_foreground_address_region->get_region_list($pid, $level, $if_id_key);
            //var_dump($region_list); exit();
            self::add_view_data('region_list', $region_list);
            
            if(!is_array($region_list)){
                $result['status']  = -400;
                $result['message'] = '获取失败';
            }else{
                $result['status']  = 1;
                $result['message'] = '获取成功';
            }
        }
        
        self::set_view_status($result['status']);
        self::set_view_message($result['message']);
    }
}